package com.ourteam.product.api;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.IProductUITabItemDAO;
import com.ourteam.product.ui.dao.ProductUITabItemDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUITabItemBean;

public class ProductUITabItemSearchModel extends AbstractSearchModel<ProductUITabItemDAOQueryBean> {

	private long tabId;

	public long getTabId() {
		return tabId;
	}

	public void setTabId(long tabId) {
		this.tabId = tabId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUITabItemBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUITabItemDAOQueryBean queryBean) throws Exception {

		ProductUITabItemDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		criteria.andTabIdEqualTo(tabId);

		if (queryBean.getSortProperties().isEmpty()) {
			queryBean.setSortProperty(IProductUITabItemDAO.SortIndex);
		}

	}

}
